from openai import OpenAI
from pydantic import BaseModel
from typing import Any

class MessageContent(BaseModel):
    role: str
    content: str = None
    id: str = None
    tool_calls: Any = None
    tool_call_id: str = None
    reasoning_content: str = None

def deepseek(messages, model, tools=None, tool_call_id = None, stream=True):
    model = 'deepseek-chat' if not model else model
    client = OpenAI(api_key="sk-6303e0c01d0e4775acf03f3a21a457e0", base_url="https://api.deepseek.com")
    if tools and len(tools) > 0:
        completion = client.chat.completions.create(
            model=model,
            messages=messages,
            tools=tools,
            stream=True
        )
    else:
        completion = client.chat.completions.create(
            model=model,
            messages=messages,
            stream=True
        )
    if stream:
        for chunk in completion:
            yield chunk.choices[0].delta